package drds.global_transaction.api.message_codec.request_and_response.transaction;

import drds.common.Log;
import drds.global_transaction.api.api.RpcContext;
import drds.global_transaction.api.message_codec.Message;
import drds.global_transaction.api.message_codec.RequestMessage;
import lombok.extern.slf4j.Slf4j;

import java.nio.ByteBuffer;

@Slf4j
public abstract class TransactionRequest extends RequestMessage
{
	private static final long serialVersionUID = 1L;

	/**
	 * TransactionRequest的子类默认是1024,其他的Message都是512
	 */
	public TransactionRequest()
	{
		// super(Message.$1024);构造方法重写改为方法重载
	}

	@Override
	public ByteBuffer createByteBuffer()
	{// 默认是512字节,子类可以对该数字进行修改
		ByteBuffer byteBuffer = ByteBuffer.allocate(Message.$1024);
		Log.output(log, byteBuffer.hashCode() + " " + byteBuffer.position() + " " + this.getClass().getSimpleName());
		return byteBuffer;
	}

	//
	public abstract TransactionResponse handle(RpcContext rpcContext);

}
